package com.zhf.testpool;

import com.zhf.utils.DruidUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Author: ZhaoHuanfeng
 * @Date: 2020/9/24 22:00
 */
public class TestDruid {

    public static void main(String[] args) throws SQLException {
        //从连接池获取连接
        Connection connection = DruidUtils.getConnection();

        //获取语句执行对象
        Statement statement = connection.createStatement();

        //执行查询
        ResultSet resultSet = statement.executeQuery("select ename from employee where salary between 3000 and 5000");

        //处理结果集
        while (resultSet.next()){
            System.out.println(resultSet.getString("ename"));
        }

        //释放资源
        DruidUtils.close(connection,statement,resultSet);
    }
}
